<?php 
require_once '../../config.php';
require_once '../../function.php';
//获取要删除的数据的id;
$id = $_POST['id'];
//连接数据库
$connect = connect();
//sql语句
$sql = "delete from posts where id ='{$id}'";
//执行sql语句
$result =mysqli_query($connect,$sql);
//返回前端数据
$response = ["code"=>0,"msg"=>"删除失败"];
if($result){ 
	$response["code"] = 1;
	$response["msg"]  = "操作成功";
 }
//以json格式返回数据
 header("content-type:application/json; charset=utf-8");
    echo json_encode($response);
 ?>